package be.xios.ti.droodle;

import java.awt.event.*;

/**
 * @author Kris Hermans
 */
public class FillCircleDrawAction extends ShapeDrawAction {
	private CircleShape cShape;

	/**
	 * @param panel
	 */
	protected FillCircleDrawAction(ShapeJPanel panel) {
		super(panel);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see be.hogelimb.ti.droodle.ShapeDrawAction#doClick(java.awt.event.MouseEvent)
	 */
	protected void doClick(MouseEvent e) {
		switch (getClickCount()) {
		case 1:
			shape = new CircleShape();
			cShape = (CircleShape) shape;
			cShape.setX(e.getX());
			cShape.setY(e.getY());
			cShape.setColor(panel.getForeground());
			cShape.setSize(5);
			cShape.setFilled(true);
			break;

		case 2:
			int dy = Math.abs(e.getY() - cShape.getY());
			int dx = Math.abs(e.getX() - cShape.getX());
			double r = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
			cShape.setRadius((int) r);
			ready();
			setClickCount(0);
			break;

		default:
			System.err.println("niet mogelijk");
		}

	}

}